home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 Christmas / macformat-045.iso / Shareware Plus / Developers / NGL1.5.0E(fat)DEMO / Font Sample(PPC) / Font_Sample(PPC).c < prev   
Encoding:
C/C++ Source or Header  |  1996-07-19  |  2.2 KB  |  93 lines  |  [TEXT/CWIE]

  1. /*============================================================
  2.  
  3.                     N_Font sample program
  4.                     
  5. ============================================================*/
  6.  
  7. #include    "N_Library.h"
  8.  
  9. WindowPtr     CreateWindow         (Str255 name);
  10.  
  11. #define        WindowSizeX        640
  12. #define        WindowSizeY        480
  13.  
  14. short        NewWindowX;
  15. short        NewWindowY;
  16.  
  17. short        Data_Rsrc = 0;
  18.  
  19. WindowPtr    window;
  20.  
  21.  
  22. //counter
  23. long        counter1 = 123456;
  24. long        counter2 = 99999;
  25.  
  26. short        x = -100;
  27. short        x2 = 640;
  28.  
  29. void main(void)
  30. {
  31.     ToolboxInit();
  32.     ColorCheck();
  33.     HideCursor();
  34.     window = CreateWindow("\pN Game Library <Font Sample>");
  35.     N_Window_Set(window,NewWindowX,NewWindowY,WindowSizeX,WindowSizeY);    //set up window
  36.     Open_Resource_File(128,1,&Data_Rsrc);
  37.     N_Sp_Make(640,480);                                                //set up for sprites
  38.     N_Cel_Make(65536);                                                //set up for cel
  39.     N_Font_Init();
  40.     N_Sprite_Set(129,0,14,24,1,11,1,0);                                    //set sprites
  41.     N_Sprite_Set(130,11,12,16,1,13,4,0);
  42.  
  43.     N_Font_Set(0,0,0,0x80000000,0);                                        //set fonts
  44.     N_Font_Set(1,0x80000000+11,0,0x80000000+26+11,0x80000000+37+11);
  45.  
  46.     N_Pict_Draw(128,0,0,(GrafPtr)SP_off,true);                                //draw background
  47.     Close_Resource_File(&Data_Rsrc);
  48.  
  49.     do
  50.     {
  51.         N_Num_Put(counter1,x,80,8,16,0,1,0);                                    //(x,80)ÅAspace16,8segments,fontset0,cel plane  0-
  52.         N_Num_Put(counter2,x,138,8,14,1,1,24);                                //(x,160)ÅAspace14,8segments,fontset1,cel plane  24-
  53.         N_Font_Put("\pN GAME LIBRARY SAMPLE PROGRAM!",x2,180,14,1,1,30);
  54.         counter1++;                                                        //updates counters
  55.         counter2-=64;
  56.         if (counter1 >= 99999999) counter1 = 0;
  57.         if (counter2 <= 0) counter2 = 99999;
  58.     
  59.         x = x+1;                                                            //move
  60.         if (x >= 640) x=-100;
  61.  
  62.         x2-=2;
  63.         if (x2 <= -500) x2=640;
  64.  
  65.     
  66.         N_Cel_Loop(0,0);
  67.     }
  68.     while (!Button());
  69.     ShowCursor();
  70.     ColorRevert();
  71. }
  72.  
  73.  
  74. WindowPtr CreateWindow (Str255 name)
  75. {
  76.     short        centerX,centerY;
  77.     short        windowWidth,windowHeight;
  78.  
  79.     window = GetNewWindow (128,nil,(WindowPtr)-1L );
  80.     centerX  = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
  81.     centerY  = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
  82.     SetWTitle(window,name);
  83.     MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
  84.     SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
  85.     ShowWindow(window);
  86.     SetPort((GrafPtr)window );
  87.     return (WindowPtr)window;
  88. }
  89.     
  90.  
  91.  
  92.  
  93.